package com.ruoyi.project.baozhi.employee1.controller;

import java.util.List;
import java.util.UUID;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.baozhi.employee1.domain.OrgEmployee1;
import com.ruoyi.project.baozhi.employee1.service.IOrgEmployee1Service;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 人员1Controller
 * 
 * @author ruoyi
 * @date 2021-12-06
 */
@Controller
@RequestMapping("/baozhi/employee1")
public class OrgEmployee1Controller extends BaseController
{
    private String prefix = "baozhi/employee1";

    @Autowired
    private IOrgEmployee1Service orgEmployee1Service;

    @RequiresPermissions("baozhi:employee1:view")
    @GetMapping()
    public String employee1()
    {
        return prefix + "/employee1";
    }

    /**
     * 查询人员1列表
     */
    @RequiresPermissions("baozhi:employee1:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(OrgEmployee1 orgEmployee1)
    {
        startPage();
        List<OrgEmployee1> list = orgEmployee1Service.selectOrgEmployee1List(orgEmployee1);
        return getDataTable(list);
    }

    @RequiresPermissions("baozhi:employee1:list1")
    @PostMapping("/list1")
    @ResponseBody
    public TableDataInfo list1(OrgEmployee1 orgEmployee1)
    {
        startPage();
        List<OrgEmployee1> list = orgEmployee1Service.selectOrgEmployee1List1(orgEmployee1);
        return getDataTable(list);
    }

    /**
     * 导出人员1列表
     */
    @RequiresPermissions("baozhi:employee1:export")
    @Log(title = "人员1", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(OrgEmployee1 orgEmployee1)
    {
        List<OrgEmployee1> list = orgEmployee1Service.selectOrgEmployee1List(orgEmployee1);
        ExcelUtil<OrgEmployee1> util = new ExcelUtil<OrgEmployee1>(OrgEmployee1.class);
        return util.exportExcel(list, "人员1数据");
    }

    /**
     * 新增人员1
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存人员1
     */
    @RequiresPermissions("baozhi:employee1:add")
    @Log(title = "人员1", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(OrgEmployee1 orgEmployee1)
    {
        orgEmployee1.setOrgDeptEmployeeId(UUID.randomUUID().toString().replace("-","").substring(0,8));

        return toAjax(orgEmployee1Service.insertOrgEmployee1(orgEmployee1));
    }

    /**
     * 修改人员1
     */
    @GetMapping("/edit/{orgDeptEmployeeId}")
    public String edit(@PathVariable("orgDeptEmployeeId") String orgDeptEmployeeId, ModelMap mmap)
    {
        OrgEmployee1 orgEmployee1 = orgEmployee1Service.selectOrgEmployee1ByOrgDeptEmployeeId(orgDeptEmployeeId);
        mmap.put("orgEmployee1", orgEmployee1);
        return prefix + "/edit";
    }

    /**
     * 修改保存人员1
     */
    @RequiresPermissions("baozhi:employee1:edit")
    @Log(title = "人员1", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(OrgEmployee1 orgEmployee1)
    {
        return toAjax(orgEmployee1Service.updateOrgEmployee1(orgEmployee1));
    }

    /**
     * 删除人员1
     */
    @RequiresPermissions("baozhi:employee1:remove")
    @Log(title = "人员1", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(orgEmployee1Service.deleteOrgEmployee1ByOrgDeptEmployeeIds(ids));
    }
}
